<!--   每个商品显示的标签   -->
<template>
  <div class="goods-item">
    <img :src="product.pic" :alt="product.pname" />
    <div class="goods-info">
      <p>{{ product.pname }}</p>
      <span class="price"><small>$</small>{{ product.price }}</span>
      <span class="collect">
        <!-- 收藏小图标-->
        <el-icon :size="10" color="#f7ba2a">
          <Star />
        </el-icon>
        <span>{{ product.collectcount }}</span>
      </span>
    </div>
  </div>
</template>

<script>
import { Star } from "@element-plus/icons-vue";

export default {
  components: {
    Star,
  },
  props: {
    product: Object,
    default() {
      return {};
    },
  },
};
</script>

<style scoped>
.goods-item {
  width: 45%;
  padding-bottom: 40px;
  position: relative;
}
img {
  width: 100%;
  border-radius: 5px;
}
.goods-info {
  font-size: 12px;
  position: absolute;
  bottom: 5px;
  left: 0;
  right: 0;
  overflow: hidden;
  text-align: center;
}
p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 3px;
}
.price {
  color: red;
  margin-right: 20px;
}
.collect {
  position: relative;
}
</style>
